package com.lianbang.pharmacy.model

import cn.ubest.mvvmcore.base.BaseModel
import cn.ubest.mvvmcore.bean.ListWrapper
import cn.ubest.mvvmcore.bean.ResultWrapper
import cn.ubest.mvvmcore.bean.Wrapper
import com.lianbang.pharmacy.bean.*
import com.lianbang.pharmacy.http.api.UserApi

/**
 * Created by maoqi on 2020/12/18.
 */
class UserModel : BaseModel() {
    private val c = UserApi::class.java

    suspend fun login(account: String, pwd: String): ResultWrapper<LoginBean> {
        return createService(c).login(account, pwd)
    }

    suspend fun getUser(): ResultWrapper<UserBean> {
        return createService(c).getUser()
    }

    suspend fun register(
        account: String,
        pwd: String,
        conf_pwd: String,
        real_name: String,
        phone: String
    ): Wrapper {
        return createService(c).register(account, pwd, conf_pwd, real_name, phone)
    }

    suspend fun userSignInfo(): ResultWrapper<UserSignBean> {
        return createService(c).userSignInfo()
    }

    suspend fun sign(): ResultWrapper<SignBean> {
        return createService(c).sign()
    }

    suspend fun addressList(): ListWrapper<AddressListBean> {
        return createService(c).addressList()
    }

    suspend fun addOrChangeAddress(address: AddressListBean): Wrapper {
        return createService(c).addOrChangeAddress(
            address.id,
            address.real_name,
            address.phone,
            address.is_default,
            address.province,
            address.city,
            address.district,
            address.detail,
            address.post_code
        )
    }

    suspend fun deleteAddress(id: Int): Wrapper {
        return createService(c).deleteAddress(id)
    }

    suspend fun couponList(): ListWrapper<CouponListBean>{
        return createService(c).couponList()
    }

}